<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
use think\facade\Route;

/**
 * 附件相关路由
 */
Route::group('wf', function () {
    /**模型分类**/
    Route::group(function () {
        Route::post('category/batch_remove', 'v1.wf.Category/batchRemove')->option(['real_name' => '批量删除模型分类']);
        Route::resource('category', 'v1.wf.Category')->except(['create', 'edit'])->option([
            'real_name' => [
                'index'  => '获取模型分类列表',
                'save'   => '保存模型分类',
                'update' => '修改模型分类',
                'delete' => '删除模型分类',
            ],
        ]);
    })->option(['parent' => 'wf', 'cate_name' => '模型分类']);

    /**模型设计**/
    Route::group(function () {
        Route::post('designer/batch_remove', 'v1.wf.Designer/batchRemove')->option(['real_name' => '批量删除模型']);
        Route::post('designer/save_define', 'v1.wf.Designer/saveDefine')->option(['real_name' => '保存模型定义']);
        Route::get('designer/approve/list', 'v1.wf.Designer/approveList')->option(['real_name' => '审批人列表']);
        Route::get('designer/approve/get', 'v1.wf.Designer/approveInfo')->option(['real_name' => '审批人详情']);
        Route::resource('designer', 'v1.wf.Designer')->except(['create', 'edit'])->option([
            'real_name' => [
                'index'  => '获取模型列表',
                'save'   => '保存模型',
                'update' => '修改模型',
                'delete' => '删除模型',
            ],
        ]);
    })->option(['parent' => 'wf', 'cate_name' => '模型设计']);

    /**流程定义**/
    Route::group(function () {
        Route::put('process/set_status/:id/:status', 'v1.wf.Process/setStatus')->option(['real_name' => '更新流程状态']);
        Route::resource('process', 'v1.wf.Process')->except(['create', 'edit'])->option([
            'real_name' => [
                'index'  => '获取定义列表',
                'save'   => '保存流程定义',
                'update' => '修改流程定义',
                'delete' => '删除流程定义',
            ],
        ]);
    })->option(['parent' => 'wf', 'cate_name' => '流程定义']);

    /**流程实例**/
    Route::group(function () {
        Route::post('order/highLightData', 'v1.wf.Order/highLightData')->option(['real_name' => '获取高亮数据']);
        Route::post('order/get', 'v1.wf.Order/get')->option(['real_name' => '获取任务详情']);
        Route::post('order/takeBack', 'v1.wf.Order/takeBack')->option(['real_name' => '取回流程']);
        Route::post('order/undo', 'v1.wf.Order/undo')->option(['real_name' => '作废流程']);
        Route::post('order/cascadeRemove', 'v1.wf.Order/cascadeRemove')->option(['real_name' => '删除流程']);
        Route::resource('order', 'v1.wf.Order')->except(['create', 'edit'])->option([
            'real_name' => [
                'index'  => '获取实例列表',
                'save'   => '保存实例定义',
                'update' => '修改流程定义',
                'delete' => '删除流程定义',
            ],
        ]);
    })->option(['parent' => 'wf', 'cate_name' => '流程实例']);

    /**流程任务**/
    Route::group('task', function () {
        Route::get('donelist', 'v1.wf.Task/doneList')->option(['real_name' => '我的代办']);
        Route::get('todolist', 'v1.wf.Task/todolist')->option(['real_name' => '我的已办']);
        Route::post('execute', 'v1.wf.Task/execute')->option(['real_name' => '执行任务']);
        Route::post('backoff', 'v1.wf.Task/backOff')->option(['real_name' => '任务驳回']);
        Route::post('get', 'v1.wf.Task/get')->option(['real_name' => '获取任务详情']);
        Route::post('listHisByOrderId', 'v1.wf.Task/listHisByOrderId')->option(['real_name' => '获取实例历史记录']);
    })->option(['parent' => 'wf', 'cate_name' => '流程任务']);

//    Route::get('task/test', 'v1.wf.Task/test')->option(['real_name' => 'task']);

})->middleware([
    \phoenix\middleware\AllowCrossOriginMiddleware::class,
    \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
    \app\adminapi\middleware\AdminAuthPermissionMiddleware::class,
    \app\adminapi\middleware\AdminLogMiddleware::class,
])->option(['mark' => 'wf', 'mark_name' => '工作流程']);
